#coding=utf-8
#!/usr/bin/python

'''
Created on 2012-11-17

@author: Neo.Chen
'''

import sqlite3

def create_sqlite_table(conn, table_name, sql):
    try:
        cn = conn.cursor()
        query_sql = "select count(*) from sqlite_master where type='table' and name='%s'" % (table_name)
        cn.execute(query_sql)
        res = cn.fetchall()
        print(res)                  #是一个二维列表 [(1,)]
        for line in res:
            print(line)             #得到一维列表 (1,)
            existTable = line[0]    #表是否已经存在
            print(existTable)

        if existTable != 1:
            cn.execute(sql)
            conn.commit()
        cn.close()
    except:
        print("create_sqlite_table error")

##################################################################################

def main():
    print("main start...")

if __name__ == '__main__':
    main()



















